package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.ProjectPlanDto;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursing/plan")
@Api(tags = "护理计划相关接口")
public class NursingPlanController extends  BaseController {

@Autowired
private NursingPlanService nursingPlanService;

@GetMapping("/search")
    @ApiOperation("条件分页查询")
    public ResponseResult selectByPage(@ApiParam(value = "护理计划")  String plan_name, Integer status, Integer pageNum, Integer pageSize){
    PageResponse pageResponse = nursingPlanService.selectByPage(plan_name, status, pageNum, pageSize);
    return ResponseResult.success(pageResponse);
}

@PostMapping
    @ApiOperation("新增")
    public ResponseResult add(@RequestBody ProjectPlanDto projectPlanDto){
nursingPlanService.add(projectPlanDto);
    return success();
}


    /**
     *根据id查询护理计划
     */
    @GetMapping("/{id}")
    @ApiOperation("根据id查询")
    public ResponseResult<NursingPlanVo> getById(@ApiParam(value = "id") @PathVariable("id") Integer id){
        NursingPlanVo nursingPlanVo    =nursingPlanService.findByid(id);
        return success(nursingPlanVo);
    }
//
///**
// * 修改
// */
//@PutMapping
//    @ApiOperation("修改")
//    public ResponseResult update(@RequestBody ProjectPlanDto projectPlanDto){
//        nursingPlanService.update(projectPlanDto);
//        return success();
//}

    /**
     * 删除
     */
    @DeleteMapping("{id}")
    @ApiOperation("删除")
    public ResponseResult delete(@ApiParam(value = "id") @PathVariable("id") Integer id){
        nursingPlanService.delete(id);
        return success();
    }
    /**
     * 启用禁用
     */
    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用禁用")
    public ResponseResult updateStatus(@ApiParam(value = "id") @PathVariable("id") Integer id, @ApiParam(value = "状态") @PathVariable("status") Integer status){
nursingPlanService.updateStatus(id,status);
return success();
    }
/**
 * 查询所有护理计划
 */
@PutMapping
    @ApiOperation("查询所有护理计划")
    public ResponseResult selectAll(){
List<NursingPlanVo> list = nursingPlanService.selecAll();
    return success(list);

}
}
